T_RECT = 1
T_LINE = 2
T_CIRCLE = 3

function newObj(id,type,d)
  local obj = {}

  obj.id = id
  obj.type = type
  obj.d = d

  return obj
end

function newLine(p1x,p1y,p2x,p2y)
  local line = {}

  line.p1 = {}
  line.p1.x = p1x
  line.p1.y = p1y

  line.p2 = {}
  line.p2.x = p2x
  line.p2.y = p2y

  return line
end

function newLineObj(id,p1x,p1y,p2x,p2y)
  return newObj(id,T_LINE,newLine(p1x,p1y,p2x,p2y))
end

function newRect(minx,miny,maxx,maxy)
  local rect = {}

  rect.minx = minx
  rect.miny = miny
  rect.maxx = maxx
  rect.maxy = maxy

  return rect
end

function newRectObj(id,minx,miny,maxx,maxy)
  return newObj(id,T_RECT,newRect(minx,miny,maxx,maxy))
end

function newCircle(x,y,r)
  local circle = {}

  circle.center = {}
  circle.center.x = x
  circle.center.y = y

  circle.r = r

  return circle
end

function newCircleObj(id,x,y,r)
  return newObj(id,T_CIRCLE,newCircle(x,y,r))
end

